import { createBrowserRouter } from 'react-router-dom'
import AuthRoute from '@/components/AuthRoute'
import Login from '@/pages/Login'
import Layout from '@/pages/Layout'

import {AuthToken} from '@/utils/index'
import { lazy, Suspense } from 'react'
const Home = lazy(() => import('@/pages/Home'))
const Acticle = lazy(() => import('@/pages/Acticle'))
const Publish = lazy(() => import('@/pages/Publish'))
const router = createBrowserRouter([
  {
    path: '/',
    element: <AuthRoute><Layout /></AuthRoute>,
    children: [{
      path: '/',
      element:<Suspense fallback="加载中"> <Home /></Suspense>,

    },{
      path: '/acticle',
      element: <Suspense fallback="加载中"> <Acticle /></Suspense>,

    },
{
      path: '/publish',
      element: <Suspense fallback="加载中"> <Publish /></Suspense>,

    },
  ]
  },
  {
    path: '/login',
    element: <Login />,
  },
])

export default router